<template>
    <el-dialog v-if="dialogVisible" :close-on-click-modal='false' title="编辑拍摄" :visible.sync="dialogVisible" @close="resetForm('shotSzRef')" width="400px">
        <el-form label-position="top" label-width="auto" size="medium" :hide-required-asterisk='true' :model="shotSzForm" :rules="shotSzRules" ref="shotSzRef" v-loading="loading">
            <el-form-item label="拍摄" prop="photographer_uid">
                <el-select v-model="shotSzForm.photographer_uid" :multiple-limit="10" multiple collapse-tags filterable placeholder="请选择拍摄" style="width:100%">
                    <el-option :label="item.nickname" :value="item.id" v-for="(item,index) in shotList" :key="index"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="resetForm('shotSzRef')" class="el-button-width" size="small">取 消</el-button>
            <el-button type="primary" @click="submitForm('shotSzRef')" class="el-button-width" size="small" :disabled='disabled' :loading="disabled">确 定</el-button>
        </span>
    </el-dialog>
</template>

<script>
export default {
    name: "",
    data() {
        return {
            disabled: false,
            dialogVisible: false,
            shotList:[],
            material_finish:null,
            shotSzForm: {
                id: "",
                photographer_uid:[],
            },
            shotSzRules: {
                // photographer_uid: [
                //     {
                //         required: true,
                //         message: "请选择拍摄",
                //         trigger: ["blur","change"],
                //     },
                // ],
            },
        };
    },

    created() {
       
    },
    methods: {
        // 提交添加
        submitForm(formName) {
            this.$refs[formName].validate(async (valid) => {
                if (valid) {
                    if (this.material_finish == 1) {
                        this.$confirm("需求发生变化，提交后已提交的素材将被清除，确定吗？", "清除", {
                            confirmButtonText: "确认",
                            cancelButtonText: "取消",
                        })
                            .then(async () => {
                                this.submitJust()
                            })
                            .catch(() => { });
                    } else {
                        this.submitJust()
                    }
                } else {
                    this.disabled = false;
                    return false;
                }
            });
        },

        async submitJust() {
            this.disabled = true;
            const { data: res } = await this.$http.post(
                "adminapi/demandsz/videoPhotographer",
                this.shotSzForm
            );
            if (res.code !== 200) {
                this.disabled = false;
                this.$message.error(res.msg);
                return;
            } else {
                this.$message({
                    message: "保存成功",
                    type: "success",
                });
                this.$emit("getDataList")
                this.disabled = false;
                this.resetForm('shotSzRef');
            }
        },

        // 获取深圳拍摄
        async getShotList() {
            const { data: res } = await this.$http.post(
                "adminapi/company/szPhotographerList"
            );
            if (res.code !== 200) {
                this.$message.error(res.msg);
                return;
            } else {
                this.shotList = res.data;
            }
        },

        // 关闭重置表单
        resetForm(formName) {
            this.$refs[formName].resetFields();
            this.dialogVisible = false;
        },
    },
};
</script>
<style scoped>
</style>

